@echo off
setlocal EnableDelayedExpansion

cd /d %~dp0
protoc --version

set protoPath=%1
set outputPath=%2

if exist %outputPath% (
    rd /s /q %outputPath%
)

for /r %protoPath% %%i in (*.proto) do (  
    set filePath=%%~dpi
    set output=%outputPath%!filePath:%protoPath%=!
    if not exist !output! (
        mkdir !output!
    )
    protoc.exe --proto_path=%protoPath% --csharp_out=!output! %%i
)